<?php

namespace Plugins\ApiDoc\Http\Admin\Controller\Admin;

use App\Util\Response;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\View\Render;
use Plugins\ApiDoc\Http\Admin\Service\ApiDocService;
use Psr\Http\Message\ResponseInterface;

/**
 * 文档控制器
 *
 * Class DocumentController
 */
#[Controller('api-doc')]
class DocumentController
{
    /**
     * @param Render $render
     *
     * @return ResponseInterface
     */
    #[GetMapping('')]
    public function view(Render $render): ResponseInterface
    {
        return $render->render("plugins.ApiDoc.Admin.Document.view");
    }

    #[GetMapping('request-code')]
    public function requestCode(Render $render): ResponseInterface
    {
        return $render->render("plugins.ApiDoc.Admin.Document.request_code");
    }


    /**
     * 文档数据
     *
     * @throws \Exception
     */
    #[GetMapping('data')]
    public function doc(): ResponseInterface
    {
        return Response::json()->success(
            ApiDocService::aop(false)->get()
        );
    }
}